home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Utilities / Programming / EnterAct 3.5 / Drag_on Modules / hAWK programs / $LogDaemon < prev    next >
Encoding:
Text File  |  1992-11-27  |  2.4 KB  |  76 lines  |  [TEXT/KEEN]

  1. #$LogDaemon : this program is meant to be run in concurrent mode
  2. # only. Stop it either with <Command><period> or by copying the
  3. # word "quitit" in your calling application. All right, so it's
  4. # a new word. This program runs transparently behind the calling
  5. # app, waiting for "logit" to appear on the clipboard. When it
  6. # does, the NEXT bit of text that you copy will be appended to
  7. # a log file, together with a date stamp. You'll see the menu
  8. # bar flash to acknowledge copying "logit", and again after
  9. # appending your next copy to the log file. The name of the
  10. # log file is hard-coded in the variable "logFile" below, and
  11. #----------------------------------------
  12. # you should change the name of this file to one of your own
  13. #----------------------------------------
  14. # before running this program. Your calling app must be the
  15. # front application in order for this to work, since it is
  16. # the calling application's private clip that is monitored,
  17. # not the system clip.
  18.  
  19. # No input or variables are required.
  20.  
  21. # This sort of trigger can be used to any purpose. A slightly
  22. # "clumsier" approach would be to check for the existence of a file,
  23. # and if found then take action, and delete the file, eg
  24. #    ....looping forever....
  25. #    if (exists(triggerFile))
  26. #        {
  27. #        TakeAction()
  28. #        remove(triggerFile)
  29. #        }
  30. # -- this file-based approach does have the advantage that it can
  31. # be used while the calling app, and hAWK, are in the background.
  32. # Multiple messages can be passed to trigger alternate actions,
  33. # even to the point of calling specific hAWK programs via the
  34. # "hAWK()" function.
  35.  
  36. # If you think up a use for this sort of "daemon", you can use
  37. # this file as a skeleton.
  38.  
  39. BEGIN {
  40.     # Change "logFile" path to a real directory on one of your disks
  41.     # - either type it in, or use $EchoFullPathNames to retrieve the
  42.     # name and location of an existing file.
  43.     logFile = "Diskname:junk:Dummy log"
  44.     while (1)
  45.         {
  46.         if ((newClip = getclip(7)) != oldClip)
  47.             {
  48.             oldClip = newClip
  49.             if (newClip == "logit")
  50.                 {
  51.                 pending = 1
  52.                 beep(0) # 0 flashes the menu bar
  53.                 }
  54.             else if (newClip == "quitit")
  55.                 {
  56.                 exit
  57.                 }
  58.             else if (pending)
  59.                 {
  60.                 fullClip = getclip()
  61.                 FlogLog()
  62.                 pending = 0
  63.                 beep(0) # 0 flashes the menu bar
  64.                 }
  65.             }
  66.         }
  67.     }
  68.  
  69. # append the time to the log file
  70. function FlogLog()
  71.     {
  72.     print time() >> logFile
  73.     print fullClip >> logFile
  74.     fullClip = "" #just in case it was huge
  75.     close(logFile)
  76.     }